package com.example.lean;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void myClick(View v) {
        //方式1 component 实例化
        ComponentName cn = new ComponentName(this, "com.example.lean.SecondActivity");
        Intent intent = new Intent();
        intent.setComponent(cn);
        startActivity(intent);

        //方式2 setClass 实例化
        //Intent intent = new Intent();
        //intent.setClass(this, SecondActivity.class);
        //startActivity(intent);

        //方式3 构造函数
        //Intent intent = new Intent(this, SecondActivity.class);
        //startActivity(intent);
    }
}